// 堆栈 非递归实现 
const flatter = (arr) => {
    let stack = [...arr];
    let res = [];
    while(stack.length){
        let num = stack.pop();
        if(Array.isArray(num)) {
            stack.push(...num);
        } else {
            res.push(num);
        }
    }
    return res.reverse();
}

console.log(flatter([1,2,[3,4,[5,6]]]))